package algorithm;

/**
 * @auther zhouliangliang
 * @date 2022/10/10 18:15
 * @description 线程安全单例模式
 */
public class Singleton {
    private volatile static Singleton singleton = null;

    private Singleton() {}

    public static Singleton getInstance() {
        if(singleton == null) {
            synchronized (Singleton.class) {
                if(singleton == null) {
                    singleton = new Singleton();
                }
            }
        }
        return singleton;
    }
}
